

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>RBD 永久缓存 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="配置选项" href="../rbd-config-ref/" />
    <link rel="prev" title="映像实时迁移" href="../rbd-live-migration/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 块设备</a> &raquo;</li>
        
          <li><a href="../rbd-operations/">Ceph 块设备运维</a> &raquo;</li>
        
      <li>RBD 永久缓存</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/rbd/rbd-persistent-cache.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 块设备</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../rados-rbd-cmds/">基本命令</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../rbd-operations/">运维</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../rbd-snapshot/">快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-exclusive-locks/">互斥锁</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-mirroring/">镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-live-migration/">实时迁移</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">永久缓存</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">共享、只读的父映像缓存</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">不可变对象缓存守护进程</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-config-ref/">配置选项 (librbd)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-replay/">RBD 重放</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-integrations/">对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="rbd">
<h1>RBD 永久缓存<a class="headerlink" href="#rbd" title="Permalink to this headline">¶</a></h1>
<span class="target" id="index-0"></span><div class="section" id="id1">
<h2>共享、只读的父映像缓存<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p><a class="reference external" href="../rbd-snapshot/#layering">Cloned RBD images</a> from a parent usually only modify a small portion of
the image. For example, in a VDI workload, the VMs are cloned from the same
base image and initially only differ by hostname and IP address. During the
booting stage, all of these VMs would re-read portions of duplicate parent
image data from the RADOS cluster. If we have a local cache of the parent
image, this will help to speed up the read process on one host, as well as
to save the client to cluster network traffic.
RBD shared read-only parent image cache requires explicitly enabling in
<code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code>. The <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon is responsible for
caching the parent content on the local disk, and future reads on that data
will be serviced from the local cache.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>RBD shared read-only parent image cache requires the Ceph Nautilus release or later.</p>
</div>
<div class="section" id="id2">
<h3>启用 RBD 的共享只读父映像缓存功能<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>To enable RBD shared read-only parent image cache, the following Ceph settings
need to added in the <code class="docutils literal notranslate"><span class="pre">[client]</span></code> <a class="reference external" href="../../rados/configuration/ceph-conf/#configuration-sections">section</a> of your <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">parent</span> <span class="n">cache</span> <span class="n">enabled</span> <span class="o">=</span> <span class="n">true</span>
<span class="n">rbd</span> <span class="n">plugins</span> <span class="o">=</span> <span class="n">parent_cache</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="id3">
<h2>不可变对象缓存守护进程<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon is responsible for caching parent
image content within its local caching directory. For better performance it’s
recommended to use SSDs as the underlying storage.</p>
<p>The key components of the daemon are:</p>
<ol class="arabic simple">
<li><p><strong>Domain socket based IPC:</strong> The daemon will listen on a local domain
socket on start up and wait for connections from librbd clients.</p></li>
<li><p><strong>LRU based promotion/demotion policy:</strong> The daemon will maintain
in-memory statistics of cache-hits on each cache file. It will demote the
cold cache if capacity reaches to the configured threshold.</p></li>
<li><p><strong>File-based caching store:</strong> The daemon will maintain a simple file
based cache store. On promotion the RADOS objects will be fetched from
RADOS cluster and stored in the local caching directory.</p></li>
</ol>
<p>On opening each cloned rbd image, <code class="docutils literal notranslate"><span class="pre">librbd</span></code> will try to connect to the
cache daemon over its domain socket. If it’s successfully connected,
<code class="docutils literal notranslate"><span class="pre">librbd</span></code> will automatically check with the daemon on the subsequent reads.
If there’s a read that’s not cached, the daemon will promote the RADOS object
to local caching directory, so the next read on that object will be serviced
from local file. The daemon also maintains simple LRU statistics so if there’s
not enough capacity it will delete some cold cache files.</p>
<p>Here are some important cache options correspond to the following settings:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">immutable_object_cache_sock</span></code> The path to the domain socket used for
communication between librbd clients and the ceph-immutable-object-cache
daemon.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">immutable_object_cache_path</span></code> The immutable object cache data directory.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">immutable_object_cache_max_size</span></code> The max size for immutable cache.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">immutable_object_cache_watermark</span></code> The watermark for the cache. If the
capacity reaches to this watermark, the daemon will delete cold cache based
on the LRU statistics.</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon is available within the optional
<code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> distribution package.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p><code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon requires the ability to
connect RADOS clusters.</p>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon should use a unique Ceph user ID.
To <a class="reference external" href="../../rados/operations/user-management#add-a-user">create a Ceph user</a>, with <code class="docutils literal notranslate"><span class="pre">ceph</span></code> specify the <code class="docutils literal notranslate"><span class="pre">auth</span> <span class="pre">get-or-create</span></code>
command, user name, monitor caps, and OSD caps:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">auth</span> <span class="n">get</span><span class="o">-</span><span class="ow">or</span><span class="o">-</span><span class="n">create</span> <span class="n">client</span><span class="o">.</span><span class="n">ceph</span><span class="o">-</span><span class="n">immutable</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="n">cache</span><span class="o">.</span><span class="p">{</span><span class="n">unique</span> <span class="nb">id</span><span class="p">}</span> <span class="n">mon</span> <span class="s1">&#39;allow r&#39;</span> <span class="n">osd</span> <span class="s1">&#39;profile rbd-read-only&#39;</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> daemon can be managed by <code class="docutils literal notranslate"><span class="pre">systemd</span></code> by specifying the user
ID as the daemon instance:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">systemctl</span> <span class="n">enable</span> <span class="n">ceph</span><span class="o">-</span><span class="n">immutable</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="n">cache</span><span class="nd">@immutable</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="n">cache</span><span class="o">.</span><span class="p">{</span><span class="n">unique</span> <span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> can also be run in foreground by <code class="docutils literal notranslate"><span class="pre">ceph-immutable-object-cache</span></code> command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">immutable</span><span class="o">-</span><span class="nb">object</span><span class="o">-</span><span class="n">cache</span> <span class="o">-</span><span class="n">f</span> <span class="o">--</span><span class="n">log</span><span class="o">-</span><span class="n">file</span><span class="o">=</span><span class="p">{</span><span class="n">log_path</span><span class="p">}</span>
</pre></div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../rbd-config-ref/" class="btn btn-neutral float-right" title="配置选项" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../rbd-live-migration/" class="btn btn-neutral float-left" title="映像实时迁移" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>